package com.Database;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class DatabaseHelper extends SQLiteOpenHelper {

	private static final int VERSION = 1;
	private static final String DATABASE_NAME_STRING = "sdjzu_db.db";
	
	private static final String JDTB = "JDTB";
	private static final String KQresult = "KQresult";
	private static final String QJInfo = "QJInfo";
	private static final String RWTB = "RWTB";
	private static final String Students = "Students";
	private static final String Teachers = "Teachers";
	private static final String UserInf = "UserInf";
	
	private String JDTBSql = "CREATE TABLE JDTB"
			+ "(Jno INTEGER PRIMARY KEY , Rno INTEGER,Cname VARCHAR,Tname VARCHAR,Jclass VARCHAR,Jweek VARCHAR,Jtime VARCHAR,Jtype VARCHAR,Jaddress VARCHAR,StartTime VARCHAR,EndTime VARCHAR,IsKQ VARCHAR)";
	private String KQresultSql = "CREATE TABLE KQresult"
			+ "(Kno INTEGER,Jno INTEGER,Sno VARCHAR PRIMARY KEY ,Kstate VARCHAR,Kmarks VARCHAR,InMan VARCHAR,InTime VARCHAR,IsSubmin VARCHAR,StateChanged VARCHAR)";
	private String QJInfoSql = "CREATE TABLE QJInfo"
			+ "(Qno INTEGER PRIMARY KEY,Sno VARCHAR,StartTime VARCHAR,EndTime VARCHAR,"
			+ "CountDays INTEGER,NowTime VARCHAR,Reason VARCHAR,IsOk VARCHAR,FirstMan VARCHAR,LastMan VARCHAR )";
	private String RWTBSql = "CREATE TABLE RWT"
			+ "( Rno INTEGER PRIMARY KEY,Cno VARCHAR,Tname VARCHAR,Rclass VARCHAR,Rterms VARCHAR,Rweek VARCHAR)";
	private String StudentsSql = "CREATE TABLE Students"
			+ "(Sno VARCHAR PRIMARY KEY,Sname VARCHAR,Ssdept VARCHAR,Sclass VARCHAR,Sstate VARCHAR,"
			+ "Spwd VARCHAR,Ppwd VARCHAR,Stel VARCHAR,Ptel VARCHAR,Ssex VARCHAR)";
	private String TeachersSql = "CREATE TABLE Teachers"
			+ "(Tno VARCHAR PRIMARY KEY,Tname VARCHAR,Tsdept VARCHAR,Temail VARCHAR,Ttel VARCHAR,Tpwd VARCHAR)";
	private String UserInfSql="CREATE TABLE UserInf"+"(Uno VARCHAR,Upwd VARCHAR,Uname VARCHAR PRIMARY KEY,Uclass VARCHAR,Utype VARCHAR,Utel VARCHAR)";
	
	public DatabaseHelper(Context context) {
		super(context, DATABASE_NAME_STRING,null, VERSION);
		// TODO Auto-generated constructor stub
	}
	@Override
	public void onCreate(SQLiteDatabase db) {
		// TODO Auto-generated method stub
		db.execSQL(JDTBSql);
		db.execSQL(KQresultSql);
		db.execSQL(QJInfoSql);
		db.execSQL(StudentsSql);
		db.execSQL(TeachersSql);
		db.execSQL(UserInfSql);
		db.execSQL(RWTBSql);
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int arg1, int arg2) {
		// TODO Auto-generated method stub
		onCreate(db);
	}

}
